# url="ftp://igs.gnsswhu.cn/pub/gps/data/daily/2018/021/18p/BRDM00DLR_S_20200210000_01D_MN.rnx.gz"
# BRD?00DLR_S_20200210000_01D_MN.rnx.gz
# wget -nd -r -A "BRD?00DLR_S_20200210000_01D_MN.rnx.gz" ftp://igs.gnsswhu.cn/pub/gps/data/daily/2020/021/20p/ -P test_down/
import os
import numpy as np
from ppgnss import gnss_time

year_from, doy_from = 2020, 355
year_to, doy_to = 2021, 12
local_dir = "./data"
jd_from = gnss_time.doy2jd(year_from, doy_from)
jd_to = gnss_time.doy2jd(year_to, doy_to)
for jd in np.arange(jd_from, jd_to+1):
    year, doy = gnss_time.jd2doy(jd)
    url="ftp://igs.gnsswhu.cn/pub/gps/data/daily/%04d/%03d/%02dp/BRDM00DLR_S_%04d%03d0000_01D_MN.rnx.gz" %(
        year, doy, year-2000, year, doy)
    cmd = "wget -P %s %s" %(local_dir, url)
    print(cmd)
    os.system(cmd)
